﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVCOA.Helper;
namespace MVCOA
{
    public class SearchController :Controller
    {
        //
        // GET: /Search/

        public ActionResult Result(string name,int type)
        {
            if (type == 1)
            {//相应一级页面

            }
            else if (type == 2)
            {//二级页面
                IBLL.ICate_SecondBLL secBll = OperateContext.Current.BLLSession.ICate_SecondBLL;
                var cateSecList = secBll.GetListBy(q => q.name == name);
                if (cateSecList.Count > 0)
                {
                    MODEL.Cate_Second cateSec = cateSecList.First();
                    IBLL.IEsDetailBLL esBll = OperateContext.Current.BLLSession.IEsDetailBLL;
                    string strId = cateSec.id.ToString();
                    ViewBag.list = esBll.GetListBy(q => q.cateSecondId.Equals(strId));
                }           
                else
                    return Redirect("~/Views/Shared/Error.cshtml");
                
            }
            else if (type == 3)
            {//3级页面
            
                IBLL.ICate_ThirdBLL thiBll = OperateContext.Current.BLLSession.ICate_ThirdBLL;
                var cateThirdList = thiBll.GetListBy(q => q.name == name);
                if (cateThirdList.Count > 0)
                {
                    MODEL.Cate_Third cateThi = cateThirdList.First();
                    IBLL.IEsDetailBLL esBll = OperateContext.Current.BLLSession.IEsDetailBLL;
                    string strId = cateThi.id.ToString();
                    ViewBag.list = esBll.GetListBy(q => q.cateThirdId == strId);
                }
                else
                    return Redirect("~/Views/Shared/Error.cshtml");
            
             
            }
            else
            {//404
                return Redirect("~/Views/Shared/Error.cshtml");
            }
            return View();
        }

    }
}
